/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package giuliani_mapelli_marocco.entity;

import giuliani_mapelli_marocco.enumerations.WeatherMessageType;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "weathernotification")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Weathernotification.findAll", query = "SELECT w FROM Weathernotification w"),
    @NamedQuery(name = "Weathernotification.findById", query = "SELECT w FROM Weathernotification w WHERE w.id = :id"),
    @NamedQuery(name = "Weathernotification.findBySeen", query = "SELECT w FROM Weathernotification w WHERE w.seen = :seen"),
    @NamedQuery(name = "Notification.findByWeatherType", query = "SELECT n FROM Weathernotification n WHERE n.type = :type"),
    @NamedQuery(name = "Weathernotification.findBySuggestedDate", query = "SELECT w FROM Weathernotification w WHERE w.suggestedDate = :suggestedDate"),
    @NamedQuery(name = "Weathernotification.findByEvent", query = "SELECT w FROM Weathernotification w WHERE w.idEvent = :idEvent")})
public class Weathernotification implements Serializable {
    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(optional = false)
    @NotNull
    private Long id;
    
    @Basic(optional = false)
    @NotNull
    private boolean seen;

    @Temporal(TemporalType.DATE)
    private Date suggestedDate;
    
    @Basic(optional = false)
    @NotNull
    private WeatherMessageType type;

    @JoinColumn(name = "addressee", referencedColumnName = "username")
    @ManyToOne(optional = false)
    private User addressee;
    
    @JoinColumn(name = "idEvent", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Event idEvent;

    public Weathernotification() {
    }

    public Weathernotification(Long id) {
        this.id = id;
    }

    public Weathernotification(Long id, boolean seen) {
        this.id = id;
        this.seen = seen;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public boolean getSeen() {
        return seen;
    }

    public void setSeen(boolean seen) {
        this.seen = seen;
    }

    public Date getSuggestedDate() {
        return suggestedDate;
    }

    public void setSuggestedDate(Date suggestedDate) {
        this.suggestedDate = suggestedDate;
    }

    public User getAddressee() {
        return addressee;
    }

    public void setAddressee(User addressee) {
        this.addressee = addressee;
    }
    
    public WeatherMessageType getType() {
        return type;
    }

    public void setType(WeatherMessageType type) {
        this.type = type;
    }

    public Event getIdEvent() {
        return idEvent;
    }

    public void setIdEvent(Event idEvent) {
        this.idEvent = idEvent;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Weathernotification)) {
            return false;
        }
        Weathernotification other = (Weathernotification) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "giuliani_mapelli_marocco.entity.Weathernotification[ id=" + id + " ]";
    }
    
}
